<!DOCTYPE html>
<html>
<head>
    <title>促销优惠配置信息</title>
    <#include "/header.html">
    <style>
        .ui-jqgrid tr.jqgrow td {
            white-space: normal !important;
            height:auto;
            vertical-align:text-top;
            padding-top:2px;
            word-break:break-all;
        }
    </style>
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn">
            <form class="form-inline" role="form">
                <div class="form-group">
                    <a @click="reset">
                        <i class="fa fa-refresh"></i>
                    </a>
                </div>&nbsp;&nbsp;&nbsp;
                <a class="btn btn-primary btn-sm " @click="query">
                    <i class="fa fa-search"></i>&nbsp;查询</a>
                <div class="form-group">
                    <select class="form-control input-sm" v-model="q.policyType">
                        <option disabled value="">促销方式</option>
                        <option v-for="item in policyTypeEnum" :value="item.value">{{item.describe}}</option>
                    </select>
                </div>&nbsp;&nbsp;&nbsp;
                <div class="form-group">
                    <input type="text" class="form-control input-sm" v-model="q.name"placeholder="活动名称">
                </div>&nbsp;&nbsp;&nbsp;
                <#if shiro.hasPermission("promotion:promotionpolicyconfig:save")>
                <a class="btn btn-primary btn-sm" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
            </#if>
            <#if shiro.hasPermission("promotion:promotionpolicyconfig:update")>
            <a class="btn btn-primary btn-sm" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
        </#if>
        <#if shiro.hasPermission("promotion:promotionpolicyconfig:delete")>
        <a class="btn btn-primary btn-sm" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
    </#if>
    </form>
</div>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
</div>

<div v-show="!showList" class="panel panel-default col-sm-4">
    <div class="panel-heading">{{title}}</div>
    <form class="form-horizontal">
        <div class="form-group">
            <div class="col-sm-2 control-label">促销方式</div>
            <div class="col-sm-10">
                <select class="form-control input-sm" v-model="promotionPolicyConfig.policyType">
                    <option v-for="item in policyTypeEnum" :value="item.value">{{item.describe}}</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>活动名称</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="promotionPolicyConfig.name" placeholder="活动名称"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>活动详细描述</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="promotionPolicyConfig.describes" placeholder="活动详细描述"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">活动范围类型</div>
            <div class="col-sm-10">
                <select class="form-control input-sm" v-model="promotionPolicyConfig.scopeType">
                    <option v-for="item in scopeTypeEnum" :value="item.value">{{item.describe}}</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>参与范围值</div>
            <div class="col-sm-10">
                <!--单品 组合-->
                <div v-for="(item,index) of scopeValueList" v-if="promotionPolicyConfig.scopeType=='sku'||promotionPolicyConfig.scopeType=='group'">
                    <div class="input-group" id="sku">
                        <span class="input-group-addon">sku:</span>
                        <input class="form-control" type="text" v-model="scopeValueList[index]">
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="button" @click="addOpt">+</button>
                            <button class="btn btn-default" type="button" @click="delOpt(index)">-</button>
                        </span>
                    </div>
                </div>
                <!--品牌-->
                <div v-if="promotionPolicyConfig.scopeType=='brand'">
                    <select class="form-control input-sm" v-model="promotionPolicyConfig.scopeValue" id="brand">
                        <option v-for="item in goodsBrandList" :value="item.brandId">{{item.brandName}}</option>
                    </select>
                </div>
                <!--品类-->
                <div v-for="(item,index) of categoryList" v-if="promotionPolicyConfig.scopeType=='category'">
                    <div class="input-group" id="category">
                        <span class="input-group-addon">品类ID:</span>
                        <input class="form-control" type="number" v-model="categoryList[index]">
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="button" @click="addcategory">+</button>
                            <button class="btn btn-default" type="button" @click="delcategory(index)">-</button>
                        </span>
                    </div>
                </div>
                <!--全场-->
                <div v-if="promotionPolicyConfig.scopeType=='all'">
                    <input type="text" class="form-control input-sm" value="0" readonly>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">移除的品类ID:</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="delobj.category" placeholder="多个ID之间请用逗号分隔.如:1844,1845"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">移除的skuID:</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="delobj.sku" placeholder="多个ID之间请用逗号分隔.如:220198,220196"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>活动开始展示时间</div>
            <div class="col-sm-10">
                <input class="form-control input-sm" v-model="promotionPolicyConfig.showDate" @click="showDateTime"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>活动开始时间</div>
            <div class="col-sm-10">
                <input class="form-control input-sm" v-model="promotionPolicyConfig.beginDate" @click="beginDateTime"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>活动结束时间</div>
            <div class="col-sm-10">
                <input class="form-control input-sm" v-model="promotionPolicyConfig.endDate" @click="endDateTime"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>优惠券有效天数</div>
            <div class="col-sm-10">
                <input type="number" class="form-control input-sm" v-model="promotionPolicyConfig.validDays" placeholder="优惠券有效天数"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>延迟使用天数</div>
            <div class="col-sm-10">
                <input type="number" class="form-control input-sm" v-model="promotionPolicyConfig.delayedUseDays" placeholder="延迟使用天数（多少天后开始有效）"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>特价产品是否参与优惠券</div>
            <div class="col-sm-10">
                <select v-model="promotionPolicyConfig.specialPartake" class="form-control input-sm">
                    <option value=false>不参与</option>
                    <option value=true>参与</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>适用平台</div>
            <div class="col-sm-10">
                <template>
                    <el-checkbox-group v-model="checkeds" :min="1">
                        <el-checkbox v-for="item in purviewEnum" :label="item.value" :key="item.id">{{item.describe}}</el-checkbox>
                    </el-checkbox-group>
                </template>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>用户类型限制</div>
            <div class="col-sm-10">
                <template>
                    <el-checkbox-group v-model="userTypeList" :min="1">
                        <el-checkbox label="common">一般用户</el-checkbox>
                        <el-checkbox label="shop">图文店用户</el-checkbox>
                        <el-checkbox label="company">企业用户</el-checkbox>
                        <el-checkbox label="designer">设计师</el-checkbox>
                        <el-checkbox label="pop">供应商</el-checkbox>
                    </el-checkbox-group>
                </template>
            </div>
        </div>
        <div v-if="promotionPolicyConfig.policyType=='promotion'">
        <div class="form-group">
            <div class="col-sm-2 control-label">用户等级阶梯限制</div>
            <div class="col-sm-10">
                <div class="input-group">
                    <span class="input-group-btn">
                        <input type="button" class="btn btn-default  btn-sm" @click="dialogVisible = true" value="点击设置阶梯限制"/>
                        </span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>每订单参与次数限制</div>
            <div class="col-sm-10">
                <input type="number" class="form-control input-sm" v-model="promotionPolicyConfig.orderLimitTimes" placeholder="每订单参与次数限制"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>用户参与次数限制</div>
            <div class="col-sm-10">
                <input type="number" class="form-control input-sm" v-model="promotionPolicyConfig.userLimitTimes" placeholder="用户参与次数限制"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>总数参与次数限制</div>
            <div class="col-sm-10">
                <input type="number" class="form-control input-sm" v-model="promotionPolicyConfig.allLimitTimes" placeholder="总数参与次数限制"/>
            </div>
        </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>优惠条件类型</div>
            <div class="col-sm-10">
                <select v-model="promotionPolicyConfig.conditionType" class="form-control input-sm">
                    <option value="none">无门槛</option>
                    <option value="fullmoney">满钱</option>
                    <option value="fullquantity">满数量</option>
                    <option value="groupmustone">组合满一</option>
                </select>
            </div>
        </div>
        <div class="form-group" v-if="promotionPolicyConfig.conditionType=='fullmoney'||promotionPolicyConfig.conditionType=='fullquantity'">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>优惠条件参数</div>
            <div class="col-sm-10">
                <input type="number" class="form-control input-sm" v-model="promotionPolicyConfig.conditionParam" placeholder="条件参数"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>优惠结果类型</div>

            <div class="col-sm-10">
                <select v-model="promotionPolicyConfig.resultType" class="form-control input-sm">
                    <option value="fullreduce">减钱</option>
                    <option value="franking">免邮</option>
                    <option value="fullgive">满赠</option>
                    <option value="sale">折扣</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>优惠结果参数</div>
            <div class="col-sm-10">
                <input v-if="promotionPolicyConfig.resultType!='fullgive'" type="number" class="form-control input-sm" v-model="conResult" placeholder="优惠结果参数"/>
                <div v-if="promotionPolicyConfig.resultType=='fullgive'">
                    <div class="input-group" v-for="(item,index) of skuList">
                        <span class="input-group-addon">sku:</span>
                        <input class="form-control" type="number" v-model="item.sku">
                        <span class="input-group-addon">数量:</span>
                        <input class="form-control" type="number" v-model="item.quantity">
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="button" @click="addsku">+</button>
                            <button class="btn btn-default" type="button" @click="delsku(index)">-</button>
                        </span>
                        <input type="text" v-model="item.goodsType" v-show="false">
                    </div>

                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"><span style="color: red">*&nbsp;</span>使用平台</div>
            <div class="col-sm-10">
                <select v-model="promotionPolicyConfig.stageType" class="form-control input-sm">
                    <option value=0> 紫云网、pop平台</option>
                    <option value=1>紫云网</option>
                    <option value=2>pop平台</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">活动优先级</div>
            <div class="col-sm-10">
                <input type="text" class="form-control input-sm" v-model="promotionPolicyConfig.level" placeholder="活动优先级"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label">是否平台券</div>
            <div class="col-sm-10">
                <el-radio v-model="isAlatform" label=1>是</el-radio>  <!--shop_id=0-->
                <el-radio v-model="isAlatform" label=0>否</el-radio>  <!--shop_id=1-->
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-2 control-label"></div>
            <input type="button" class="btn btn-primary  btn-sm" @click="saveOrUpdate" value="确定"/>
            &nbsp;&nbsp;<input type="button" class="btn btn-warning  btn-sm" @click="showList=!showList" value="返回"/>
        </div>
    </form>
</div>
<div class="col-sm-8" v-show="!showList">
    <div class="col-sm-5" height="100%" style="padding-left: 55px;width: 51%">
        <div class="grid-btn">
            <form class="form-inline" role="form">
                <el-button type="info" plain @click="choiceCategory()">
                    点击添加品类ID和商品ID
                </el-button>

            </form>
        </div>
        <template v-if="spuTableData != null">
            <div class="panel-heading"><span style="color: red">*温馨提示:双击查看分类下的产品</span></div>
            <el-table :data="spuTableData" width="90%" stripe @cell-dblclick="choiceSpu" style="width: 100%">
                <el-table-column prop="goodsId" label="商品id" width="80"></el-table-column>
                <el-table-column prop="name" label="商品名" ></el-table-column>
            </el-table>
        </template>
    </div>
    <div class="col-sm-5" style="border-left:1px  #000;float: right;margin-top: 39px">
        <template v-if="skuTableData != null" height="100%">
            <div class="panel-heading"><span style="color: red">*温馨提示:双击可添加sku至参与范围值中</span></div>
            <el-table :data="skuTableData" width="90%" @cell-dblclick="choiceSku" stripe style="width: 100%">
                <el-table-column prop="productId" label="产品id" width="120"></el-table-column>
                <el-table-column prop="totalPrice" label="产品价格" width="120"></el-table-column>
                <el-table-column prop="optionNames" label="产品规格选项" width="180"></el-table-column>
            </el-table>
        </template>
    </div>
</div>
<!-- 商品三级分类选择 -->
<el-dialog title="选择" :visible.sync="goodsCategoryDialogVisible" width="40%">
    <div class="el-form-item">
        <label class="el-form-item__label" style="width: 80px;">商品分类</label>
        <div class="el-form-item__content" style="margin-left: 80px;">
            <el-cascader style="width: 90%"
                         v-model="categoryId"
                         :options="categoryTree"
                         @change="categoryChange">
            </el-cascader>
        </div>
    </div>
    </span>
</el-dialog>
<!--用户等级阶梯限制-->
<el-dialog
        title="用户等级阶梯限制"
        :visible.sync="dialogVisible"
        width="30%" >
    <span>贵宾会员</span><input type="number" class="form-control input-sm" v-model="stepMap.gb"/>
    <span>黄金会员</span><input type="number" class="form-control input-sm" v-model="stepMap.hj"/>
    <span>白金会员</span><input type="number" class="form-control input-sm" v-model="stepMap.bj"/>
    <span>特殊贵宾</span><input type="number" class="form-control input-sm" v-model="stepMap.ts"/>
    <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>

</div>

<script src="${request.contextPath}/statics/js/modules/promotion/promotionpolicyconfig.js?_${.now?long}"></script>
<style>
    .el-button.is-round {
        border-radius: 20px;
        padding: 2px 3px;

    }
    .el-button--info.is-plain {
        color: #909399;
        background: #f4f4f5;
        border-color: #d3d4d6;
        padding-top: 6px;
        padding-bottom: 6px;
    }
    .form-control.a.input-sm{
        width:80px;
    }
</style>
</body>
</html>